<?php
//Start session
	@session_start();
	
	//Include database connection details
	require_once('inc/config.inc');
	//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
	$query =  mysql_query("INSERT INTO courses (course_title,description,teacher_id,numOfStudents,startdate,finishdate,address,category_id) values('$_GET[cname]', '$_GET[desc]', '$_GET[teacher_id]', '$_GET[numStd]','$_GET[from]','$_GET[to]','$_GET[address]','$_GET[course_cat]')");
	if($query){
		header("Location: ../courses.php?add=success");
	}
	else{
		header("Location: ../courses.php?add=fail");
	}

	?>